unit RoaGrid;

interface

uses
  SysUtils,
  Classes,
  DBGrids,
  Dialogs,
  Grids,
  Mask,
  Messages,
  Windows,
  Controls,
  DB;

type

  TRoaDBGrid = class(TDBGrid)
  private
    procedure _wndproc(var Message: Messages.TMessage);
  protected
    procedure DrawColumnCell(const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); override;
  public
    constructor Create(AOwner: Classes.TComponent); override;
  end;
  {end;}

implementation

procedure Register;
begin
  RegisterComponents('ROA', [TRoaDBGrid]);
end;

type THackControl = class(TControl);

procedure TRoaDBGrid._wndproc(var Message: Messages.TMessage);
var
  Distance: System.Integer;
begin
  case Message.Msg of
    WM_MOUSEWHEEL:
      begin
        Distance := 1;
        if (Message.WParamHi <= Windows.WHEEL_DELTA) then
          Distance := Distance * (-1);
        if (System.Assigned(Self.DataLink.DataSet)) then
          Self.DataLink.DataSet.MoveBy(Distance);
      end;
  else
    THackControl(Self).WndProc(Message);
  end;
end;

constructor TRoaDBGrid.Create(AOwner: Classes.TComponent);
begin
  inherited Create(AOwner);
  Self.WindowProc := _wndproc;
end;

procedure TRoaDBGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  Cell: TGridCoord;
begin
  if (not Assigned(Column.Field)) then
    Exit;

  { Desenha um ListBox }
  if (Column.PickList.Count > 0) then
  begin
  end
  else
    { Desenha um checkBox }
    if (Column.Field.DataType = ftBoolean) then
    begin
    end;

  inherited DrawColumnCell(Rect, DataCol, Column, State);
end;

end.
